import React, { useEffect, useState } from 'react'
export default function App() {
  const [count, setCount] = useState(10)
  let timer = null
  const handleClick = () => {
    console.log(timer)
    clearInterval(timer)
    timer = setInterval(() => {
      setCount((count) => count - 1)
    }, 5000)
  }
  return (
    <div>
      <h3>{count}</h3>
      <button onClick={handleClick}>开始倒计时</button>
    </div>
  )
}
